home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gsl.idb / usr / freeware / share / aclocal / gsl.m4.z / gsl.m4
Text File  |  2000-10-09  |  6KB  |  167 lines

  1. # Configure path for the GNU Scientific Library
  2. # Christopher R. Gabriel <cgabriel@linux.it>, April 2000
  3.  
  4.  
  5. AC_DEFUN(AM_PATH_GSL,
  6. [
  7. AC_ARG_WITH(gsl-prefix,[  --with-gsl-prefix=PFX   Prefix where GSL is installed (optional)],
  8.             gsl_prefix="$withval", gsl_prefix="")
  9. AC_ARG_WITH(gsl-exec-prefix,[  --with-gsl-exec-prefix=PFX Exec prefix where GSL is installed (optional)],
  10.             gsl_exec_prefix="$withval", gsl_exec_prefix="")
  11. AC_ARG_ENABLE(gsltest, [  --disable-gsltest       Do not try to compile and run a test GSL program],
  12.             , enable_gsltest=yes)
  13.  
  14.   if test x$gsl_exec_prefix != x ; then
  15.      gsl_args="$gsl_args --exec-prefix=$gsl_exec_prefix"
  16.      if test x${GSL_CONFIG+set} != xset ; then
  17.         GSL_CONFIG=$gsl_exec_prefix/bin/gsl-config
  18.      fi
  19.   fi
  20.   if test x$gsl_prefix != x ; then
  21.      gsl_args="$gsl_args --prefix=$gsl_prefix"
  22.      if test x${GSL_CONFIG+set} != xset ; then
  23.         GSL_CONFIG=$gsl_prefix/bin/gsl-config
  24.      fi
  25.   fi
  26.  
  27.   AC_PATH_PROG(GSL_CONFIG, gsl-config, no)
  28.   min_gsl_version=ifelse([$1], ,0.2.5,$1)
  29.   AC_MSG_CHECKING(for GSL - version >= $min_gsl_version)
  30.   no_gsl=""
  31.   if test "$GSL_CONFIG" = "no" ; then
  32.     no_gsl=yes
  33.   else
  34.     GSL_CFLAGS=`$GSL_CONFIG $gslconf_args --cflags`
  35.     GSL_LIBS=`$GSL_CONFIG $gslconf_args --libs`
  36.  
  37.     gsl_major_version=`$GSL_CONFIG $gsl_args --version | \
  38.            sed 's/^\([[0-9]]*\).*/\1/'`
  39.     if test "x${gsl_major_version}" = "x" ; then
  40.        gsl_major_version=0
  41.     fi
  42.  
  43.     gsl_minor_version=`$GSL_CONFIG $gsl_args --version | \
  44.            sed 's/^\([[0-9]]*\)\.\?\([[0-9]]*\).*/\2/'`
  45.     if test "x${gsl_minor_version}" = "x" ; then
  46.        gsl_minor_version=0
  47.     fi
  48.  
  49.     gsl_micro_version=`$GSL_CONFIG $gsl_config_args --version | \
  50.            sed 's/^\([[0-9]]*\)\.\?\([[0-9]]*\)\.\?\([[0-9]]*\).*/\3/'`
  51.     if test "x${gsl_micro_version}" = "x" ; then
  52.        gsl_micro_version=0
  53.     fi
  54.  
  55.     if test "x$enable_gsltest" = "xyes" ; then
  56.       ac_save_CFLAGS="$CFLAGS"
  57.       ac_save_LIBS="$LIBS"
  58.       CFLAGS="$CFLAGS $GSL_CFLAGS"
  59.       LIBS="$LIBS $GSL_LIBS -lgslblasnative"
  60.  
  61.       rm -f conf.gsltest
  62.       AC_TRY_RUN([
  63. #include <stdio.h>
  64. #include <stdlib.h>
  65. #include <string.h>
  66.  
  67. char*
  68. my_strdup (char *str)
  69. {
  70.   char *new_str;
  71.   
  72.   if (str)
  73.     {
  74.       new_str = malloc ((strlen (str) + 1) * sizeof(char));
  75.       strcpy (new_str, str);
  76.     }
  77.   else
  78.     new_str = NULL;
  79.   
  80.   return new_str;
  81. }
  82.  
  83. int main ()
  84. {
  85.   int major, minor, micro;
  86.   char *tmp_version;
  87.  
  88.   system ("touch conf.gsltest");
  89.  
  90.   /* HP/UX 9 (%@#!) writes to sscanf strings */
  91.   tmp_version = my_strdup("$min_gsl_version");
  92.   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
  93.      printf("%s, bad version string\n", "$min_gsl_version");
  94.      exit(1);
  95.    }
  96.  
  97.    if (($gsl_major_version > major) ||
  98.       (($gsl_major_version == major) && ($gsl_minor_version > minor)) ||
  99.       (($gsl_major_version == major) && ($gsl_minor_version == minor) && ($gsl_micro_version >= micro)))
  100.     {
  101.       return 0;
  102.     }
  103.   else
  104.     {
  105.       printf("\n*** 'gsl-config --version' returned %d.%d.%d, but the minimum version\n", $gsl_major_version, $gsl_minor_version, $gsl_micro_version);
  106.       printf("*** of GSL required is %d.%d.%d. If gsl-config is correct, then it is\n", major, minor, micro);
  107.       printf("*** best to upgrade to the required version.\n");
  108.       printf("*** If gsl-config was wrong, set the environment variable GSL_CONFIG\n");
  109.       printf("*** to point to the correct copy of gsl-config, and remove the file\n");
  110.       printf("*** config.cache before re-running configure\n");
  111.       return 1;
  112.     }
  113. }
  114.  
  115. ],, no_gsl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  116.        CFLAGS="$ac_save_CFLAGS"
  117.        LIBS="$ac_save_LIBS -lgslblasnative"
  118.      fi
  119.   fi
  120.   if test "x$no_gsl" = x ; then
  121.      AC_MSG_RESULT(yes)
  122.      ifelse([$2], , :, [$2])     
  123.   else
  124.      AC_MSG_RESULT(no)
  125.      if test "$GSL_CONFIG" = "no" ; then
  126.        echo "*** The gsl-config script installed by GSL could not be found"
  127.        echo "*** If GSL was installed in PREFIX, make sure PREFIX/bin is in"
  128.        echo "*** your path, or set the GSL_CONFIG environment variable to the"
  129.        echo "*** full path to gsl-config."
  130.      else
  131.        if test -f conf.gsltest ; then
  132.         :
  133.        else
  134.           echo "*** Could not run GSL test program, checking why..."
  135.           CFLAGS="$CFLAGS $GSL_CFLAGS"
  136.           LIBS="$LIBS $GSL_LIBS -lgslblasnative"
  137.           AC_TRY_LINK([
  138. #include <stdio.h>
  139. ],      [ return 0; ],
  140.         [ echo "*** The test program compiled, but did not run. This usually means"
  141.           echo "*** that the run-time linker is not finding GSL or finding the wrong"
  142.           echo "*** version of GSL. If it is not finding GSL, you'll need to set your"
  143.           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  144.           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
  145.           echo "*** is required on your system"
  146.       echo "***"
  147.           echo "*** If you have an old version installed, it is best to remove it, although"
  148.           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  149.         [ echo "*** The test program failed to compile or link. See the file config.log for the"
  150.           echo "*** exact error that occured. This usually means GSL was incorrectly installed"
  151.           echo "*** or that you have moved GSL since it was installed. In the latter case, you"
  152.           echo "*** may want to edit the gsl-config script: $GSL_CONFIG" ])
  153.           CFLAGS="$ac_save_CFLAGS"
  154.           LIBS="$ac_save_LIBS -lgslblasnative"
  155.        fi
  156.      fi
  157. #     GSL_CFLAGS=""
  158. #     GSL_LIBS=""
  159.      ifelse([$3], , :, [$3])
  160.   fi
  161.   AC_SUBST(GSL_CFLAGS)
  162.   AC_SUBST(GSL_LIBS)
  163.   rm -f conf.gsltest
  164. ])
  165.  
  166.  
  167.